package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;


@Mapper
public interface UserMapper {

    @Select("select * from user where openid = #{openId}")
    User findById(String openId);

    @Options(keyProperty = "id" ,useGeneratedKeys = true)
    @Insert("insert into user values (null,#{openid},#{name},#{phone},#{sex},#{idNumber},#{avatar},#{createTime})")
    void add(User user);

    /**
     * 根据用户id查询
     * @param id
     * @return
     */
    @Select("select * from user where id = #{id}")
    User findByUid(Long id);

}
